from datetime import datetime
import zipfile
import os
import git

def zip_folder(folder_path, output_path):
    with zipfile.ZipFile(output_path, 'w', zipfile.ZIP_DEFLATED) as zipf:
        for root, dirs, files in os.walk(folder_path):
            for file in files:
                file_path = os.path.join(root, file)
                file_in_zip_path = os.path.relpath(file_path, os.path.dirname(folder_path))
                zipf.write(file_path, file_in_zip_path)

# 获取当前日期并格式化为 YYYY-MM-DD 格式
current_date = datetime.now().strftime("%Y-%m-%d")
# 使用方法
# 要压缩的文件夹路径
folder_to_compress = 'F:/v2rayN-Core'
# 输出的.zip文件名
output_zip_file = f"v2ray_1_{current_date}.zip"
zip_folder(folder_to_compress, output_zip_file)

git_path = "E:/WorkSpace/Python/vilavpn"
repo = git.Repo(git_path)
repo.git.add(all=True)
repo.git.commit("-m","定时备份文件")
repo.remotes.origin.push()
print("执行完毕")